Repository navigation
Conversation
…ene routes Server components in /scenes and /scene/[id] self-fetched via HTTP over pascal.localhost, triggering getaddrinfo ENOTFOUND on Windows runtimes where *.localhost is not resolved by OS resolver, resulting in HTTP 500. Query the scene operations singleton directly in server components, falling back to loopback fetch with .localhost normalized to 127.0.0.1. Fixes pascalorg#876 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
This PR fixes the HTTP 500 on
Start with |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FX8vGAP5g43AHR1jixUeXr
…allback The /scenes and /scene/[id] pages read scenes straight from getSceneOperations(), the same singleton the API route uses, so the HTTP fallback with its loopback rewrite could only repeat the same failure while the bare catch hid the real error. Remove it and let errors surface. Reading the store directly also bypassed the scene API guard. Rebuild a Request from the incoming headers and run guardSceneApiRequest (origin, loopback-or-PASCAL_SCENE_API_TOKEN auth, rate limit) before loading; denied requests get a 404. SETUP.md no longer claims the Docker port must stay at 3000 because the page fetched its own API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FX8vGAP5g43AHR1jixUeXr
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(editor): read scenes directly on the scene pages, behind the scene API guard
Description
What does this PR do?
Fixes #876. On Windows,
/scenesand/scene/<id>returned 500: the server-rendered pages loaded scenes by fetching their own/api/scenesendpoint over HTTP, and on Windows thepascal.localhosthost in that URL does not resolve.getSceneOperations().listScenes()/.loadStoredScene()directly. The API route uses that same singleton, so the HTTP round trip added nothing. There is no fallback and nolocalhost→127.0.0.1rewrite, so a storage error reaches the Next error page and isn't hidden.apps/editor/lib/scene-page-guard.tsrebuilds aRequestfromnext/headersand calls the existingguardSceneApiRequest. That applies the origin allow-list, auth (loopback, orPASCAL_SCENE_API_TOKENasAuthorization: Bearer/x-pascal-scene-token) and the per-IP rate limit, exactly asGET /api/scenesdoes. A denied request getsnotFound()(HTTP 404). Server components cannot return a 401 without enabling Next's experimentalauthInterrupts, and a 404 doesn't reveal whether scenes exist.SETUP.md: replaced the paragraph saying the Docker port must stay at 3000 (that limit only existed because the page fetched its own API). It now documents the guard.What doesn't change: on
localhost,*.localhost,127.0.0.1and::1with no token configured (the local dev / CLI setup), both pages work as before. A missing scene still renders the in-page "Scene not found" card.Behaviour change: a page opened through a LAN IP or a public host with no
PASCAL_SCENE_API_TOKENconfigured now gets a 404. Before this PR it got an empty list or a 500, because its internal API fetch was refused (503) for the same reason.How to test
bun test apps/editor/lib(scene-page-guard.test.tscovers loopback hosts, a non-loopback host with no token (503), a required or wrong token (401), bearer andx-pascal-scene-token, an unlisted origin (403), the rate limit (429) and a missing host).bun dev, then openhttp://localhost:3002/scenesand a saved/scene/<id>. Both load. On Windows, also checkhttp://pascal.localhost:3002/scenes.PASCAL_SCENE_API_TOKEN=secretand a client that sendsAuthorization: Bearer secret(for examplecurl -H 'Authorization: Bearer secret' http://<ip>:3002/scenes), the page renders.Screenshots / screen recording
None. Apart from the 404 for unauthorized hosts, there's no visual change.
Checklist
bun dev(not run here: this checkout lacks the private plugin packages the app imports; unit tests and type checks only)bun checkto verify)mainbranchReplies to bot review threads
(The GitHub API for pascalorg/editor wasn't reachable from this session, so these are keyed by topic. Paste each under the matching thread.)
resolveBaseUrl/ loopback rewrite (catch hides errors, duplicated helper): Removed: both pages callgetSceneOperations()directly with no fallback, so storage errors surface, and bothresolveBaseUrlcopies are gone.guardSceneApiRequest(origin, loopback-or-token auth, rate limit) throughlib/scene-page-guard.tsand return 404 when it refuses. Tests are inscene-page-guard.test.ts.NEXT_PUBLIC_APP_URL/ the Docker port note in SETUP.md: The page no longer fetches its own API, so the port constraint is gone and SETUP.md now documents the guard instead.